package com.ruoyi.develop.factory.factoryPurchaseMain.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.factory.factoryPurchaseMain.mapper.FactoryPurchaseMainMapper;
import com.ruoyi.develop.factory.factoryPurchaseMain.domain.FactoryPurchaseMain;
import com.ruoyi.develop.factory.factoryPurchaseMain.service.IFactoryPurchaseMainService;

/**
 * 采购订单信息Service业务层处理
 * @author qh
 * @date 2024-11-08
 */
@Service
public class FactoryPurchaseMainServiceImpl implements IFactoryPurchaseMainService {
    @Resource
    private FactoryPurchaseMainMapper factoryPurchaseMainMapper;

    /**
     * 查询采购订单信息
     * @param id 采购订单信息主键
     * @return 采购订单信息
     */
    @Override
    public FactoryPurchaseMain selectById(String id) {
        return factoryPurchaseMainMapper.selectById(id);
    }

    /**
     * 查询采购订单信息列表
     * @param entity 采购订单信息
     * @return 采购订单信息
     */
    @Override
    public List<FactoryPurchaseMain> selectList(FactoryPurchaseMain entity) {
        return factoryPurchaseMainMapper.selectList(entity);
    }

    /**
     * 新增采购订单信息
     * @param entity 采购订单信息
     * @return 结果
     */
    @Override
    public int insert(FactoryPurchaseMain entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return factoryPurchaseMainMapper.insert(entity);
    }

    /**
     * 修改采购订单信息
     * @param entity 采购订单信息
     * @return 结果
     */
    @Override
    public int update(FactoryPurchaseMain entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return factoryPurchaseMainMapper.update(entity);
    }

    /**
     * 批量删除采购订单信息
     * @param ids 需要删除的采购订单信息主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return factoryPurchaseMainMapper.deleteByIds(ids);
    }

    /**
     * 删除采购订单信息信息
     * @param id 采购订单信息主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return factoryPurchaseMainMapper.deleteById(id);
    }
}
